home *** CD-ROM | disk | FTP | other *** search
/ Nebula 2 / Nebula Two.iso / SourceCode / PriorityQueue / PriorityQueue.h < prev    next >
Text File  |  1995-06-12  |  3KB  |  99 lines

  1. /* NAME:
  2. **    PriorityQueue:Object
  3. **
  4. **    COPYRIGHT 1992 BY ONYSCHUK AND ASSOCIATES
  5. **    ALL RIGHTS RESERVED.
  6. **
  7. ** REVISION HISTORY:
  8. **    Sun Aug 16 14:14:03 EDT 1992    Mark Onyschuk
  9. **                    Starting point.
  10. **
  11. ** DESCRIPTION:
  12. **    A priority queue which dequeues objects by
  13. **    unsigned integer priority.
  14. **
  15. **    NOTE: priorityOf(n) > priorityOf(n + 1)
  16. **
  17. ** DISCLAIMER:
  18. **    This is free software; you can redistribute it and/or modify
  19. **    it under the terms of the GNU General Public License as
  20. **    published by the Free Software Foundation; either version
  21. **    1, or (at your option) any later version.
  22. **
  23. **    This program is distributed in the hope that it will be
  24. **    useful, but WITHOUT ANY WARRANTY; without even the implied
  25. **    warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
  26. **    PURPOSE.  See the GNU General Public License for more
  27. **    details.
  28. **
  29. **    You should have received a copy of the GNU General Public
  30. **    License along with this program; if not, write to the Free
  31. **    Software Foundation, Inc., 675 Mass Ave, Cambridge, MA
  32. **    02139, USA.
  33. */
  34.  
  35. #import <objc/Object.h>
  36.  
  37. typedef struct _NODE
  38. {
  39.     unsigned int    priority;
  40.     id            object;
  41. } NODE;
  42.  
  43.  
  44. @interface PriorityQueue:Object
  45. {
  46.     NODE        *heap;
  47.     unsigned int    size, top;
  48. }
  49.  
  50. /* INITIALIZING A PRIORITY QUEUE ****************************************/
  51.  
  52. - init;
  53. - initCount:(int)count;
  54.  
  55. /* COPYING AND FREEING A PRIORITY QUEUE *********************************/
  56.  
  57. - copyFromZone:(NXZone *)zone;
  58. - free;
  59.  
  60. /* QUEUEING AND DEQUEUEING OBJECTS BY PRIORITY **************************/
  61.  
  62. - addObject:anObject withPriority:(unsigned int)priority;
  63. - removeObject;
  64.  
  65. /* COUNTING THE NUMBER OF OBJECTS IN A PRIORITY QUEUE *******************/
  66.  
  67. - (unsigned int)count;
  68.  
  69. /* DETERMINING THE HIGHEST PRIORITY IN A PRIORITY QUEUE *****************/
  70.  
  71. - (unsigned int)highestPriority;
  72.  
  73. /* EMPTYING A PRIORITY QUEUE ********************************************/
  74.  
  75. - empty;
  76. - freeObjects;
  77.  
  78. /* COMPARING AND COMBINING PRIORITY QUEUES ******************************/
  79.  
  80. - (BOOL)isEqual:anObject;
  81. - appendQueue:(PriorityQueue *)otherQueue;
  82.  
  83. /* GETTING AND SETTING THE CAPACITY OF A PRIORITY QUEUE *****************/
  84.  
  85. - (unsigned int)capacity;
  86. - setAvailableCapacity:(unsigned int)capacity;
  87.  
  88. /* SENDING MESSAGES TO OBJECTS ******************************************/
  89.  
  90. - makeObjectsPerform:(SEL)aSelector;
  91. - makeObjectsPerform:(SEL)aSelector with:anObject;
  92.  
  93. /* ARCHIVING ************************************************************/
  94.  
  95. - read:(NXTypedStream *)stream;
  96. - write:(NXTypedStream *)stream;
  97.  
  98. @end
  99.